/*
 *  types.h
 *  kangmodb
 *
 *  Created by 강모 김 on 11. 5. 1..
 *  Copyright 2011 강모소프트. All rights reserved.
 *
 */

#ifndef _KD_TYPES_H_ 
#define _KD_TYPES_H_ (1)

#include "sqliteInt.h"

/** @brief The type for version numbers for multi version concurrency control.
 */
typedef u64 stgVersion;
/** @brief Version Number can have at most 47 bits. See stgTableData in table.h for the details. 
 */
const stgVersion MAX_DATA_VERSION = (((u64)1)<<47) -1;

/** @brief The NULL value for the version numbers 
 */
const stgVersion STG_VERSION_NULL = 0;

/** @brief The type for the unique identifier for a savepoint. Starts from 1, increases monotonously.
 */
typedef int stgSavepointId;

/** @brief The default savepoint used by total rollback. 
 */
const int STG_SAVEPOINT_0 = 0;

/** @breif The type for a table ID. 
 */
typedef u16 stgTableId;

/** @brief The type for length of key or data stored in KangmoDB.
 */
typedef u16 stgValueLength;

/** @brief The unsigned integer type that the exactly same space to hold a pointer.
 * On 64 bit machines, it is 64 bit wide.
 * On 32 bit machines, it is 32 bit wide.
 */
typedef size_t uptr;

/** @brief The type that can hold the size of a file
 */
typedef off_t filesize_t;


#define KD_MAX_U32  ((((u64)1)<<32)-1)

#define KD_MAX_U16  ((((u32)1)<<16)-1)


#define KD_STRING std::string

#define KD_STR_DATA(str) stgData(str, strlen(str))


#endif /* _KD_TYPES_H_ */
